<template>
  <view class="qrcode_selected_platform-wrap">
    <!-- 店铺审核通过 -->
    <block v-if="isHaveStore == 1">
      <view class="qrcode_selected_platform-top">
        <view class="qrcode_selected_platform-top-content">
          <view class="text-1">
            请选择
          </view>
          <view class="text-2">
            您想入驻的收款平台
          </view>
          <view class="text-3">
            <view class="line"></view>
            <image src="/static/image/qrcode/check.png" mode="" class="text-3-check-img"></image>
          </view>
        </view>
      </view>  
      <view class="qrcode_selected_platform-content">
        <image src="/static/image/qrcode/bankcard.png" mode="" class="qrcode_selected_platform-content-img bankcard-img" :class="{active: select == 1}" @click="selectChange(1)"></image>
        <image src="/static/image/qrcode/easypay.png" mode="" class="qrcode_selected_platform-content-img easypay-img" :class="{active: select == 2}" @click="selectChange(2)"></image>  
      </view> 
      <view class="qrcode_selected_platform-footer">
        <button type="primary" class="qrcode_selected_platform-footer-btn" @click="nextStep">下一步</button>
      </view>
    </block>
    <block v-else>
      <view class="no-store">
        <image :src="$store.state.imgBaseUrl + '/storeNull.png'" mode="" class="no-store-img"></image>
        <view class="no-store-tip">
          {{isHaveStore == -1 ? '您还未申请店铺，请先申请店铺！' : isHaveStore == 0 ? '您的店铺当前审核中，请审核通过后再来申请收款码！' : isHaveStore == 2 ? '您的店铺申请已经驳回，请先重新申请店铺' : isHaveStore == 3 ? '您的店铺已经下线，请先上线！' : isHaveStore == 4 ? '您的店铺申请审核失败，请重新提交！' : ''}}
        </view>
      </view>
      <view class="qrcode_selected_platform-footer" v-if="isHaveStore != 3">
        <button type="primary" class="qrcode_selected_platform-footer-btn" @click="goToStore">
          {{isHaveStore == 0 ? '查看店铺' : isHaveStore == -1 || isHaveStore == null ? '申请店铺' : isHaveStore ==  2 || isHaveStore == 4 ? '重新申请' : ''}}
        </button>
      </view>
    </block>
  </view>
</template>

<script>
import { PersonalCenter } from '@/service/user/user.service.js'
export default {
  data () {
    return {
      select: null, // 1: 银联 2：易生支付
      // isHaveStore: null, // 店铺申请状态 是否有店铺 -1未申请，0审核中，1审核通过，2驳回，3下线，4审核失败
      // isHaveEasypay: null, // 是否有易生收款码 -1未申请，0待初审,1驳回,2待签约,3待终审,4终审通过,5终审失败
      // isHaveStoreCollect: null, // 是否有银联收款码 -1未申请，0未提交,1待审核，2审核通过，3驳回
    }
  },
  computed: {
    isHaveStore () {
      return this.$store.state.userInfo.isHaveStore; // 是否有店铺（-1未申请，0审核中，1审核通过，2驳回，3下线，4审核失败）
    },
    isHaveEasypay () {
      return this.$store.state.userInfo.isHaveEasypay; // 是否有易生收款码（-1未申请，0待初审,1驳回,2待签约,3待终审,4终审通过,5终审失败） ,
    },
    isHaveStoreCollect () {
      return this.$store.state.userInfo.isHaveStoreCollect;  // 是否有银联收款码（-1未申请，0未提交,1待审核，2审核通过(未补充)，3驳回）4：审核通过（已补充）5：银联审核通过
    }
  },
  methods: {
    goToStore () {
      switch (this.isHaveStore) {
      case -1:
        uni.navigateTo({
          url: '/pages/storeManage/index'
        });
        break;
      case 0:
        uni.navigateTo({
          url: '/pages/storeManage/result'
        });
        break;
      case 2:
        uni.navigateTo({
          url: '/pages/storeManage/index?status=2'
        });
        break;
      case 4:
        uni.navigateTo({
          url: '/pages/storeManage/index'
        });
        break;
      default:
      }
    },
    getQrcodeApplyStatus () {
      PersonalCenter({}, res => {
        if (res.status == 0) {
          // this.isHaveEasypay = res.data.isHaveEasypay;
          // this.isHaveStoreCollect = res.data.isHaveStoreCollect;
          // this.isHaveStore = res.data.isHaveStore;
        }
      }, null, {showErrorMsg: true});
    },
    selectChange (type) {
      this.select = type;
    },
    nextStep () {
      if (!this.select) {
        uni.showToast({
          title: '请选择您想入驻的平台',
          icon: 'none'
        })
      } else {
        if (this.select == 1) {
          switch (this.isHaveStoreCollect) { //  // 是否有银联收款码（-1：未申请，0：提交, 1：待审核，2：审核通过(未补充)，3：驳回 4：审核通过（已补充）5：银联审核通过 6: 合同资料审核驳回  7: 合同资料审核通过
          case -1:
            uni.navigateTo({ url: '/pages/qrCode/applyBank/step1' })
            break;
          case 0:
            uni.navigateTo({ url: '/pages/qrCode/applyBank/step1' })
            break;
          case 1:
            uni.navigateTo({ url: '/pages/qrCode/result?type=1&status=1' })
            break;
          case 2:
            uni.navigateTo({ url: '/pages/qrCode/applyBank/success' })
            break;
          case 3:
            uni.navigateTo({ url: '/pages/qrCode/result?type=1&status=3' })
            break;
          case 4:
            uni.navigateTo({ url: '/pages/qrCode/result?type=1&status=4' })
            break;
          case 5:
            uni.navigateTo({ url: '/pages/qrCode/index?qrcodeType=1' })
            break;
          case 6:
            uni.navigateTo({ url: '/pages/qrCode/result?type=1&status=6' })
            break;
          case 7:
            uni.navigateTo({ url: '/pages/qrCode/result?type=1&status=7' })
            break;
          default:
          }
        } else if (this.select == 2) {
          switch (this.isHaveEasypay) { // 是否有易生收款码 -1未申请，0待初审,1驳回,2待签约,3待终审,4终审通过,5终审失败，6、微信认证成功
          case -1:
            uni.navigateTo({ url: '/pages/qrCode/applyEasypay/step1' })
            break;
          case 0:
            uni.navigateTo({ url: '/pages/qrCode/result?type=2&status=0' })
            break;
          case 1:
            uni.navigateTo({ url: '/pages/qrCode/result?type=2&status=1' })
            break;
          case 2:
            uni.navigateTo({ url: '/pages/qrCode/applyEasypay/success' })
            break;
          case 3:
            uni.navigateTo({ url: '/pages/qrCode/result?type=2&status=3' })
            break;
          case 4:
            uni.navigateTo({ url: '/pages/qrCode/result?type=2&status=4' })
            break;
          case 5:
            uni.navigateTo({ url: '/pages/qrCode/result?type=2&status=5' })
            break;
          case 6:
            uni.navigateTo({ url: '/pages/qrCode/index?qrcodeType=2' })
            break;
          default:
          }
        }
      }
    }
  },
  onShow() {
    this.getQrcodeApplyStatus();
  }
}
</script>

<style lang="scss" scoped>
  .qrcode_selected_platform-wrap {
    height: 100vh;
    position: relative;
    .no-store {
      width: 100%;
      // height: 100%;
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      padding-top: 100rpx;
      font-size: 28rpx;
      .no-store-img {
        width: 340rpx;
        height: 340rpx;
      }
      .no-store-tip {
        margin-top: 16rpx;
        font-size: 38rpx;
        font-family: PingFang SC;
        font-weight: 500;
        // color: #FFFFFF;
        text-align: center;
      }
    }
    .qrcode_selected_platform-top {
      width: 100%;
      height: 400rpx;
      background: linear-gradient(-30deg, #434343 0%, #636363 100%);
      border-radius: 0rpx 0rpx 170rpx 0rpx;
      .qrcode_selected_platform-top-content {
        padding: 99rpx 0rpx 0rpx 53rpx;
        .text-1 {
          font-size: 32rpx;
          color: #FFFFFF;
          
        }
        .text-2 {
          font-size: 42rpx;
          color: #FFFFFF;
          margin-top: 26rpx;
        }
        .text-3 {
          color: #FFFFFF;
          margin-top: 23rpx;
          display: flex;
          align-items: center;
          .line {
            width: 92rpx;
            height: 8rpx;
            background: #FFFFFF;
            opacity: 0.4;
            border-radius: 4rpx;
          }
          .text-3-check-img {
            margin-left: 38rpx;
            width: 60rpx;
            height: 60rpx;
          }
        }
      }
    }
    .active {
      box-shadow:0rpx 0rpx 28rpx 0rpx #C2AC78;
    }
    .qrcode_selected_platform-content {
      position: absolute;
      top: 360rpx;
      left: 155rpx;
      width: 340rpx;
      height: 630rpx;
      background: #FFFFFF;
      border-radius: 10rpx;
      padding: 0rpx 50rpx;
      box-shadow:0rpx 0rpx 28rpx 0rpx #ededed;
      .qrcode_selected_platform-content-img {
        width: 340rpx;
        height: 130rpx;
        border-radius: 10rpx;
      }
      .bankcard-img {
        margin: 148rpx 0rpx 72rpx;
      }
      .easypay-img {
        
      }
    }
    
    .qrcode_selected_platform-footer {
      position: absolute;
      bottom: 0rpx;
      left: 0rpx;
      width: 100%;
      height: 125rpx;
      text-align: center;
      display: flex;
      align-items: center;
      justify-content: center;
      border-top: 1rpx solid #E1E1E1;
      .qrcode_selected_platform-footer-btn {
        width: 687rpx;
        height: 90rpx;
        line-height: 90rpx;
        background-color: #434343;
        color: #F6DA99;
        font-size: 30rpx;
      }
    }
    
  }
</style>
